<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="content">
        <button id="joke" @click="obtain">获取笑话</button>
        <p id="result">
            {{message}}
        </p>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script>
        var content = new Vue({
            el: '#content',
            data: {
                message: '开始'
            },
            methods: {
                obtain: function() {
                    var that = this;
                    axios.get('https://autumnfish.cn/api/joke').then(function(success) {
                        // 把this保存起来，回调函数中直接使用保存的this
                        that.message = success.data;
                    })
                }
            }
        })
    </script>

</body>

</html>